<template>
    <view class="uni-shadow u-p-t-10" @tap.stop="examineDetail" style="background:#fff">
        <u-row customStyle="flex-wrap:wrap">
            <u-col v-for="(item,index) in list" :key="index" :span="item.span"
                class="u-m-t-20 u-font-26" style="flex-direction:row">
                <text class="u-m-r-14 uni-dec-color">{{item.title}}</text>
                <text>{{item.value}}{{item.unit}}</text>
            </u-col>
        </u-row>
    </view>
</template>

<script>
export default {
    name: 'bzj-item',
    props:{
        bzj:{
            type: Object,
            default(){
                return {}
            }
        }
    },
    data(){
        return{
            list:[
                { field:'xmmc', span:12, title:'项目名称', value:'' },
                { field:'ssqh', span:5, title:'属地名称', value:'' },
                { field:'bzjlx', span:7, title:'保证金类型', value:'' },
                { field:'sgqymc', span:12, title:'施工单位', value:'' },
                { field:'dbbxdw', span:12, title:'单位', value:'' },
                { field:'zh', span:12, title:'专户账号、保函/保险编号', value:'' },
                { field:'dbbxje', span:12, title:'担保/保险金额', value:'', unit:'万元' },
            ]
        }
    },
    watch:{
        list(){
            this.init()
        }
    },
    created() {
        this.init()
    },
    methods: {
        init(){
            this.list.map((v,i)=>{
                if( v.field == 'bzjlx' ){
                    this.getCommonDictTran('bhfl',this.bzj[v.field],v)
                }else{
                    v.value = this.bzj[v.field]?this.bzj[v.field]:'暂无数据源'
                }
            })
        },

        // 字典值转译
        getCommonDictTran(dictType,dictValue,v){
            this.$request(this,this.$apis.CommonDictTran,{dictType:dictType,dictValue:dictValue}).then(res=>{
                if( typeof(res)=='string' ){
                    v.value = res
                }else{
                    v.value = '保证金专户'
                }
            })
        },

        // 查看详情
        examineDetail(){
            uni.navigateTo({
                url: '/pages/fohf-bag/bzjDetail?id='+this.bzj.id+'&type='+this.bzj.bzjlx
            });
        }
    },
}
</script>

<style scoped lang="scss">

</style>